<template>
	<view class="Global">
		<!-- <image class="imagepage" src="/static/background@2x.png" mode=""></image> -->
		<bgImage></bgImage>
		<MyNav :title="title" bgColor="" :backIcon="isback"></MyNav>



		<scroll-view scroll-y="true" class="contentOut" :style="'height:'+scrollViewHeight+'px'">
			<view class="contentOutInner">


				<view class="contentImgAddBg" @click="chooseImage()" v-if="imgArr.length==0">
					<image class="contentImgAdd" src="../../../static/gongzuotai/shangchuan.png" mode="">
					</image>


				</view>
				<view class="contentImgAddBg" @click="chooseImage()" v-if="imgArr.length>0"
					v-for="(item,index) in imgArr">

					<image class="contentImg2" :src="apiUrl+item" mode="">
					</image>
					<view class="contentImgDeleteBg" @click.stop="deleteImg(index)">
						<image class="contentImgDelete" src="../../../static/gongzuotai/delete.png" mode="">
						</image>
					</view>
				</view>
				<text class="contentText">款式图</text>




				<view class="contentListOut">




					<view class="listContent" v-for="(item,index) in listData">

						<view class="line"></view>


						<view class="contentItem" v-if="item.type==0">

							<view class="contentItemTextLeftContent">
								<text class="contentItemTextLeft">{{item.title}}</text>
								<text class="contentItemTextLeftStart">*</text>
							</view>
							<input @input="onInputAccount(index,$event)" class="contentItemTextRight" placeholder="请填写" type="text" :value="item.Value" />


						</view>


						<view class="contentItem2" v-if="item.type==1">

							<view class="contentItemTextLeftContent">
								<text class="contentItemTextLeft">{{item.title}}</text>
								<!-- <text class="contentItemTextLeftStart">*</text> -->
							</view>
							<input @input="onInputAccount(index,$event)" class="contentItemTextRight" type="text" :value="item.Value" />

						</view>
            <view class="contentItem2" v-if="item.type==2">

              <view class="contentItemTextLeftContent">
                <text class="contentItemTextLeft">{{item.title}}</text>
              </view>
              <text class="contentItemTextLeft">{{item.Value}}</text>
            </view>





					</view>

					<view class="line"></view>



					<!-- 生产工序 start -->
					<view class="contentItem">

						<view class="contentItemTextLeftContent">
							<text class="contentItemTextLeft">生产工序</text>
							<text class="contentItemTextLeftStart">*</text>
						</view>



					</view>
					<!-- 生产工序 end -->

					<!-- 生产工序内容列表  start-->
					<view class="content_gongxu">

						<view class="listContentGongxuContent" v-for="(itemOut,index) in listDataGongxu">

							<view class="listContentGongxu" v-for="(item,index1) in itemOut.data">

								<view class="contentItem" v-if="item.type==4">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}} {{index+1}}</text>
										<text class="contentItemTextLeftStart">*</text>
									</view>
									<image class="contentItemTextLeftStartImg"
										src="../../../static/gongzuotai/shanchu-red.png" mode=""
										@click.stop="deleteData(item,index)"></image>


								</view>

								<view class="contentItem" v-if="item.type==0">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}}</text>
										<text class="contentItemTextLeftStart">*</text>
									</view>
									<input class="contentItemTextRight" type="text" :value="item.Value" @input="onInputProcess(index,index1,$event)"/>


								</view>


								<view class="contentItem2" v-if="item.type==1">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}}</text>
										<text class="contentItemTextLeftStart">*</text>
									</view>
									<input class="contentItemTextRight" type="text" :value="item.Value" placeholder="请填写" @input="onInputProcessPrice(index,index1,$event)"/>

								</view>



								<view class="contentItem2" v-if="item.type==2">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}}</text>
										<text class="contentItemTextLeftStart">*</text>
									</view>

									<view class="contentItemRightContent">
										<!--										<text class="contentItemTextLeft">{{item.Value}}</text>-->
										<input class="contentItemTextRight" type="text" :value="item.Value"  @input="onInputProcess(index,index1,$event)"/>
										<image class="contentItemRightContentImg" @click="updateData()"
											src="/static/gongzuotai/xia_jiantou@2x.png" mode="">
										</image>
									</view>

								</view>


								<view class="line"></view>
							</view>
							<view class="lineBottom"></view>
						</view>


					</view>
					<!-- 生产工序内容列表  end-->




					<!-- 添加工序按键 start-->
					<view class="contentAddBtnOut">
						<view class="contentAddBtnInner" @click="AddGongxu()">
							<image class="contentAddBtnInnerImg" src="/static/gongzuotai/shangchuan.png" mode="">
							</image>
							<text class="contentAddBtnInnerText">添加工序</text>
						</view>

					</view>
					<!--  添加工序按键  end-->






					<!-- 分扎信息 start -->
					<view class="contentItem">

						<view class="contentItemTextLeftContent">
							<text class="contentItemTextLeft">分扎信息</text>
							<text class="contentItemTextLeftStart">*</text>
						</view>



					</view>
					<!-- 分扎信息 end -->



					<!-- 分扎信息内容列表  start-->
					<view class="content_gongxu">

						<view class="listContentGongxuContent" v-for="(itemOut,index) in listDataFenzha">


							<view class="listContentGongxu" v-for="(item,index1) in itemOut.data"
								@click="Fenzha(item,index)">

								<view class="contentItem" v-if="item.type==0">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}}</text>
										<text class="contentItemTextLeftStart">*</text>
									</view>
									<input class="contentItemTextRight" type="text" :value="item.Value" placeholder="请填写" @input="onInputSplittingWages(index,index1,$event)"/>


								</view>

								<view class="contentItem" v-if="item.type==4">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}} </text>
										<text class="contentItemTextLeftStart">*</text>
									</view>
                  <input class="contentItemTextRight" type="text" :value="item.Value" placeholder="请填写" @input="onInputBundleCode(index,index1,$event)" />
									<image class="contentItemTextLeftStartImg"
										src="../../../static/gongzuotai/shanchu-red.png" mode=""
										@click.stop="deleteDataFenZha(item,index)"></image>


								</view>


								<view class="contentItem2" v-if="item.type==1">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}}</text>
										<text class="contentItemTextLeftStart">*</text>
									</view>
									<input class="contentItemTextRight" type="text" :value="item.Value" placeholder="请填写" @input="onInputSplitting(index,index1,$event)"/>

								</view>



								<view class="contentItem2" v-if="item.type==2">

									<view class="contentItemTextLeftContent">
										<text class="contentItemTextLeft">{{item.title}}</text>
										<text class="contentItemTextLeftStart">*</text>
									</view>

									<view class="contentItemRightContent">
										<text class="contentItemTextLeft">{{item.Value}}</text>
										<image class="contentItemRightContentImg"
											src="/static/gongzuotai/xia_jiantou@2x.png" mode="">
										</image>
									</view>

								</view>


								<view class="line"></view>

							</view>
							<view class="lineBottom"></view>
						</view>



					</view>
					<!-- 分扎信息内容列表  end-->



					<!-- 添加分扎按键 start-->
					<view class="contentAddBtnOut">
						<view class="contentAddBtnInner" @click="AddFenZha()">
							<image class="contentAddBtnInnerImg" src="/static/gongzuotai/shangchuan.png" mode="">
							</image>
							<text class="contentAddBtnInnerText">添加分扎</text>
						</view>

					</view>
					<!--  添加分扎按键  end-->

				</view>

			</view>


		</scroll-view>


		<view class="loginContent1" id="mainBottom">

			<button @click="createOrder()" style="color:#ffffff" class="login" type="default">{{login}}</button>
		</view>




		<!--尺码大小 点击列表弹出 start-->
		<uni-popup ref="popupBag" type="bottom">
			<view class="bagDetail">
				<text class="bagDetailUpadte">尺码大小</text>
				<view class="baseList">
					<view class="baseListItem" v-for="(item,index) in sizeListData" @click="sizeListItem(index)">

						<text v-if="item.select==false" class="baseListItemText">{{item.sizeName}}</text>
						<text v-else class="baseListItemTextSelect">{{item.sizeName}}</text>
					</view>
				</view>
				<view class="loginContent" @click="setSize()">

					<button style="color:#ffffff" class="login" type="default">{{login}}</button>
				</view>

			</view>
		</uni-popup>
		<!--尺码大小 点击列表弹出 end-->




		<!-- 颜色外观  start -->
    <uni-popup ref="popupColor" type="bottom">
      <view class="bagDetail">
        <text class="bagDetailUpadte">颜色外观</text>

        <view class="baseList">
          <view class="baseListItem" v-for="(item,index) in colorList" @click="selectColorItem(item,index)">

            <text v-if="item.select==false" class="baseListItemText">{{item.colorName}}</text>
            <text v-else class="baseListItemTextSelect">{{item.colorName}}</text>
          </view>
        </view>


        <view class="loginContent" @click="addClick()">

          <button style="color:#ffffff" class="login" type="default">{{login}}</button>
        </view>

      </view>
    </uni-popup>

<!--		<uni-popup ref="popupColor" type="bottom">
			<view class="bagDetailColor">
				<text class="bagDetailUpadte">颜色外观</text>
				<view class="baseListColor">
					<view class="baseListItemColor">

						&lt;!&ndash; 左边颜色系列 &ndash;&gt;

						<scroll-view scroll-y="true" class="baseListItemColorLeft">
							<view class="baseListItemColorLeft">

								<view class="baseListItemColorLeftInner" v-for="(item,index) in colorListData"
									@click="selectColor(item,index)">
									<view class="baseListItemColorLeftInnerItem">
										<text v-if="item.select==true"
											class="baseListItemColorLeftInnerTextSelect">{{item.colorName}}</text>
										<text v-else class="baseListItemColorLeftInnerText">{{item.colorName}}</text>
									</view>
								</view>

							</view>

						</scroll-view>

						&lt;!&ndash; 右边颜色系列对应明细 &ndash;&gt;
						<scroll-view scroll-y="true" class="baseListItemColorRight">
							<view class="baseListItemColorRight">
								<view class="baseListItemColorRightItem" >
									<view class="baseListItemColorLeftInnerItemRight" v-for="(item,index) in colorList" @click="selectColorItem(item,index)">
										<text v-if="item.select==true"
											class="baseListItemColorLeftInnerTextSelect">{{item.colorName}}</text>
										<text v-else class="baseListItemColorLeftInnerText">{{item.colorName}}</text>
									</view>
								</view>

							</view>

						</scroll-view>

					</view>
				</view>


				<view class="loginContent" @click="addClick()">

					<buttonc  style="color:#ffffff" class="login" type="default">{{login}}</buttonc>
				</view>

			</view>
		</uni-popup>-->
		<!-- 颜色外观  end -->


	</view>
</template>

<script>
	import MyNav from '@/components/customnavbar.vue'
	import bgImage from '@/components/backgroundImage.vue'
	import {
		getColorGroupList,
		getColorManagerList,
		getSizeManagerList
	} from '@/pages/api/api.js'
	import {
		updateOrder,
		getOrderOne
	} from '@/pages/api/api.js';
	import config from "@/pages/api/config";
	export default {
		components: {
			MyNav,
			bgImage
		},
		data() {
			return {

				login: '确定',

				title: '编辑修改订单',
				isback: true,

				// 尺码列表
				sizeListData: [],

				colorList: [],


				// 颜色外观列表
				colorListData: [],



				listData: [{
						title: '款号',
						Value: '',
            tableFie: 'styleName',
						type: 0
					},
					{
						title: '编号',
						Value: '',
            tableFie: 'orderCode',
						type: 0
					},
					{
						title: '客户名称',
						Value: '选填',
            tableFie: 'customerName',
						type: 1
					},

					{
						title: '客户款式',
						Value: '选填',
            tableFie: 'customerStyle',
						type: 1
					},
          {
            title: '裁床单价',
            Value: '',
            tableFie: 'price',
            type: 1
          },
          {
            title: '裁床成本',
            Value: '',
            tableFie: 'cost',
            type: 2
          }
				],

				// 生产工序列表
				listDataGongxu: [],
        oneGongxu: [{
          title: '工序',
          Value: '',
          type: 4
        },
          {
            title: '工序名称',
            Value: '',
            tableFie: 'processName',
            type: 2
          },

          {
            title: '计件工价(元)',
            Value: '',
            tableFie: 'wages',
            type: 1
          },
        ],


				// 分扎信息列表
				listDataFenzha: [],




				mainTop: '',
				bottomTop: '',
				scrollViewHeight: 0,

				listDataGongxuDataTemp: [],
				storeId: '',
				tenantId: '',


				// 临时选中的尺码
				selectSizeTemp: {},
				// 分扎中是第几个对象 默认是第一个
				fenZhaIndex: 0,
				processData: [],
				orderId: '',
				apiUrl: config.apiUrl,
				imgArr: [],
				img:''

			}
		},
    onLoad: function (option) {
      console.log('option',option)
      let item = JSON.parse(decodeURIComponent(option.item));
      let id = item.id;
      this.orderId = id
      console.log('id',id)
			const app = getApp();
			this.storeId = app.globalData.storeId
			this.tenantId = app.globalData.tenantId
      this.getOrder(id)
			this.getSizeList();
			// this.getColorGroupList();
      this.getColorManagerList('');
	 if (Object.keys(item.styleImgs).length !== 0) {
		   this.imgArr.push(item.styleImgs)
	  }
	 
		},
    onShow(){
      var that = this
      uni.$on('globleProcessEvent', function(res) {
        // console.log('3422222', res.listSizeData) //  为 B 页面传过来的值
        that.processData = res.listData
        console.log('选择工序返回数据', that.processData) //  为 B 页面传过来的值
        // 移除监听事件
        uni.$off('globleProcessEvent');
      })

      this.processData.forEach(item=>{
        let gx = JSON.parse(JSON.stringify(this.oneGongxu))
        gx.forEach(row=>{
          if(row.tableFie=='processName'){
            row.Value = item.processName
          }
          if(row.tableFie=='wages'){
            row.Value = item.wages
          }
        })
        // 工序内容
        let gongxuData = {
          data: gx
        }
        // 添加数据
        this.listDataGongxu.push(gongxuData)
      })

    },
		onReady() {

			// this.AddGongxu()
			// this.AddFenZha()
			// 获取距离顶部的距离
			let query = uni.createSelectorQuery().in(this);


			query.select('#mainBottom').boundingClientRect(data => {
				this.bottomTop = data.top
				// console.log('2底部距离', this.bottomTop);
				const app = getApp();

				this.scrollViewHeight = this.bottomTop - app.globalData.totalHeight
				// console.log('可滚动距离', this.scrollViewHeight,this.bottomTop,app.globalData.totalHeight);
			}).exec();



		},
		methods: {

			// 删除图片
			deleteImg(index) {
				// //删除操作 index数组中的下标，删除一个
				this.imgArr.splice(index, 1)

			},

			// 选择图片
			chooseImage() {
				let url = config.apiUrl
				console.log('url', url)
				let that = this
				uni.chooseImage({
					count: 1,
					// sizeType压缩图片
					sizeType: "compressed",
					success: (res) => {
						// this.imgArr =[...this.imgArr, res.tempFilePaths]
						// this.imgArr = this.imgArr.concat(res.tempFilePaths);
						console.log('xxxxxxxxx', res)
						uni.uploadFile({
							url: url + '/common/upload',
							filePath: res.tempFilePaths[0],
							name: 'file',
							formData: {},
							header: {
								'Content-Type': 'multipart/form-data', // 对于文件上传，这个通常需要设置
								'Authorization': uni.getStorageSync('token') // 添加你的token头部参数
							},
							success: (res) => {
								console.log('图片上传', res)
								let obj = JSON.parse(res.data);
								console.log('obj', obj)
								if (obj.code == 200) {
									// img = obj.fileName
									that.imgArr.push(obj.fileName);
									console.log('imgArr', that.imgArr)
								}
							},
							fail: (error) => {
								console.log('图片上传失败', error)
								uni.showToast({
									title: '图片上传失败',
									icon: 'none'
								});
							}
						})
					}
				})

			},

      onInputProcess(index,index1,e) {
        this.listDataGongxu[index].data[index1].Value=e.target.value
      },
      onInputProcessPrice(index,index1,e) {
        this.listDataGongxu[index].data[index1].Value=e.target.value
        this.countCost();
      },
      onInputSplitting(index,index1,e){
        this.listDataFenzha[index].data[index1].Value=e.target.value
      },
      onInputSplittingWages(index,index1,e){
        this.listDataFenzha[index].data[index1].Value=e.target.value
        this.countCost();
      },
      onInputBundleCode(index,index1,e){
        this.listDataFenzha[index].data[index1].Value=e.target.value
      },
      countCost(){
        let quantity = 0;
        if(this.listDataFenzha.length>0){
          this.listDataFenzha.forEach(item=>{
            item.data.forEach(row=>{
              if(row.tableFie=='quantity'){
                if(isNaN(row.Value) && (/^\d+$/).test(row.Value)){
                  quantity =  quantity+row.Value
                }
              }
            })
          })
        }
        let cost = 0;
        if(quantity>0 && this.listDataGongxu.length>0){
          this.listDataGongxu.forEach(item=>{
            item.data.forEach(row=>{
              if(row.tableFie=='wages'){
                if(isNaN(row.Value) && this.isNumberOrDecimal(row.Value)){
                  cost =  cost + (quantity * wages).toFixed(2)
                }
              }
            })
          })
          if(cost>0){
            this.listData.forEach(item=>{
              if(item.tableFie=='cost'){
                item.Value = cost;
              }
            })
          }
        }
      },
      isNumberOrDecimal(value) {
        return Number.isFinite(value) || /^-?\d*\.?\d+$/.test(value);
      },
			getOrder(id) {
				getOrderOne(id).then(res => {
					if (res.code == 200) {
						let data = res.data;
						this.listData.forEach(item => {
							if (item.tableFie == 'styleName') {
								item.Value = data.styleName
							}
							if (item.tableFie == 'orderCode') {
								item.Value = data.orderCode
							}
							if (item.tableFie == 'customerName') {
								item.Value = data.customerName
							}
							if (item.tableFie == 'customerStyle') {
								item.Value = data.customerStyle
							}
						})
						// this.listDataGongxu.forEach(item=>{

            data.processList.forEach(item=>{

              let data = []
              let gx = {
                title: '工序',
                Value: '',
                type: 4
              }
              data.push(gx)

              let gx2 = {}
              gx2.title = '工序名称',
              gx2.tableFie = 'processName',
              gx2.type = 2
              gx2.Value = item.processName
              data.push(gx2)

              let gx3 = {}
              gx3.title = '计件工价(元)',
              gx3.tableFie = 'wages',
              gx3.type = 1
              gx3.Value = item.processPrice
              data.push(gx3)
              let gongxuData = {
                data: data,
                id: item.id
              }
              this.listDataGongxu.push(gongxuData)
            })

            // this.listDataFenzha.forEach(item=>{

            data.splittingUpList.forEach(item=>{
              let data = []
              let fz = {
                title: '扎号',
                Value: item.bundleCode,
                tableFie: 'bundleCode',
                type: 4
              }
              data.push(fz)
              let fz2 = {}
              fz2.title = '数量'
              fz2.tableFie = 'quantity'
              fz2.type = 0
              fz2.Value = item.quantity
              data.push(fz2)

              let fz3 = {}
              fz3.title = '尺码大小'
              fz3.tableFie = 'sizes'
              fz3.type = 2
              fz3.Value = item.sizes
              data.push(fz3)

              let fz4 = {}
              fz4.title = '颜色外观'
              fz4.tableFie = 'colors'
              fz4.type = 2
              fz4.Value = item.colors
              data.push(fz4)

              let fz5 = {}
              fz5.title = '床号批次'
              fz5.tableFie = 'batchs'
              fz5.type = 1
              fz5.Value = item.batchs
              data.push(fz5)
              console.log('fz',data)
              let fenzhaData = {
                data : data,
                id: item.id
              }
              this.listDataFenzha.push(fenzhaData)
            })

          }
        })
      },
      // 获取编号输入框的值
      onInputAccount(index,e) {

        this.listData[index].Value=e.target.value
        // console.log('获取录入值',e.target.value,this.listData);


      },
			// 选择具体颜色
			selectColorItem(item,index){
				this.colorList.forEach((e,Index)=>{
					// 表示点击选中
					if (Index == index) {
						e.select = true
						console.log('22点击颜色', e, item);
					} else {
						e.select = false
					}

				})
			},
			// 选择左侧颜色系列
			selectColor(item, index) {

				this.colorListData.forEach((e, Index) => {
					// 表示点击选中
					if (Index == index) {
						e.select = true
						console.log('121点击颜色', e, item);

						this.getColorManagerList(e.id)

					} else {
						e.select = false
					}
				})

			},

			// 点击确认选择的尺寸
			setSize() {
				let select = '';

				this.sizeListData.forEach((item, index) => {
					// 表示点击选中
					if (item.select == true) {
						this.selectSizeTemp = item
						select = item
					}
				})
				if (select != '') {
					this.close()
				} else {
					uni.showToast({
						title: '请选择尺码',
						icon: 'none'
					});
				}


				this.listDataFenzha[this.fenZhaIndex].data.forEach((item) => {
					if (item.title == '尺码大小') {
						console.log('211尺码大小', this.fenZhaIndex);
						// item.Value=select.sizeName
						this.$set(item, 'Value', select.sizeName)
					}
				})



				console.log('1点击先选择尺寸', this.selectSizeTemp, this.listDataFenzha, this.listDataFenzha[this.fenZhaIndex]);
			},
			// 点击选择尺寸大小
			sizeListItem(e) {
				this.sizeListData.forEach((item, index) => {
					// 表示点击选中
					if (e == index) {
						item.select = true
						console.log('点击尺寸', e, item);
					} else {
						item.select = false
					}
				})
			},
			getSizeList() {
				let data = {
					storeId: this.storeId,
					tenantId: this.tenantId
				}
				getSizeManagerList(data).then(res => {
					if (res.code == 200) {
						this.sizeListData = res.data;
						//获取数据的时候foreach循环一下，添加select
						this.sizeListData.forEach((item, index) => {
							this.$set(item, 'select', false)
						})

					}
				})
			},
			getColorGroupList() {
				let data = {
					storeId: this.storeId,
					tenantId: this.tenantId
				}
				getColorGroupList(data).then(res => {
					if (res.code == 200) {
						this.colorListData = res.data;
						if (this.colorListData.length > 0) {
							//获取数据的时候foreach循环一下，添加select
							this.colorListData.forEach((item, index) => {
								this.$set(item, 'select', false)
							})
							let color = this.colorListData[0];
							this.getColorManagerList(color.id)
						}
					}
				})
			},
			getColorManagerList(groupId) {
				let data = {
					storeId: this.storeId,
					tenantId: this.tenantId,
					groupId: groupId
				}
				getColorManagerList(data).then(res => {
					if (res.code == 200) {
						this.colorList = res.data;
						//获取数据的时候foreach循环一下，添加select
						this.colorList.forEach((item, index) => {
							this.$set(item, 'select', false)
						})
					}
				})
			},
			goUrl(data) {
				console.info('goUrl', data)
				if (data.title == '颜色') {
					let list = this.colorIds.split(",")
					let parmas = {
						storeId: this.storeId,
						tenantId: this.tenantId,
						selectList: list
					}
					uni.navigateTo({
						url: '/subPackA/colorManagement/colorSelect/colorListSelect?data=' + encodeURIComponent(JSON
							.stringify(parmas)),
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
				if (data.title == '尺码') {
					let list = this.sizeIds.split(",")
					let parmas = {
						storeId: this.storeId,
						tenantId: this.tenantId,
						selectList: list
					}
					uni.navigateTo({
						url: '/subPack/sizeManagement/sizeSelect/sizeListSelect?data=' + encodeURIComponent(JSON
							.stringify(parmas)),
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
			},
			// 选择工序
			updateData() {

				let parmas = {
					storeId: this.storeId,
					tenantId: this.tenantId,
					selectList: []
				}
				uni.navigateTo({
					url: '/subPack/styleManagement/styleManagementSelect/styleManagementSelect?data=' +
						encodeURIComponent(JSON.stringify(parmas)),
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			// 删除工序操作
			deleteData(item, index) {
				this.listDataGongxu = this.listDataGongxu.filter((data, Index) => {
					return index != Index;
				})

				console.log('删除操作1');
			},
			// 添加工序
			AddGongxu() {
				// 工序内容
				let gongxuData = {
					data: this.oneGongxu
				}
				// 添加数据
				this.listDataGongxu.push(gongxuData)
				// 设置序号
				/*this.listDataGongxu.forEach((item, index) => {

					item.data.forEach((e) => {
						if (e.title == '工序') {
							e.title = '工序' + (index + 1)
						}
					})

				})*/

				console.log('1添加工序', this.listDataGongxu);
			},
			// 删除分扎
			deleteDataFenZha(item, index) {
				this.listDataFenzha = this.listDataFenzha.filter((data, Index) => {
					return index != Index;
				})

				console.log('删除操作1');
			},
			// 添加分扎
			AddFenZha() {
				let fenzhaData = {
					data: [{
							title: '扎号',
							Value: this.listDataFenzha.length+1,
              tableFie: 'bundleCole',
							type: 4
						},
						{
							title: '数量',
							Value: '0',
              tableFie: 'quantity',
							type: 0
						},
						{
							title: '尺码大小',
							Value: '请选择',
              tableFie: 'sizes',
							type: 2
						},

						{
							title: '颜色外观',
							Value: '请选择',
              tableFie: 'colors',
							type: 2
						},
						{
							title: '床号批次',
							Value: '',
              tableFie: 'batchs',
							type: 1
						}
					]
				}

				// this.listDataFenzha.push(this.listDataFenzhaData)
				this.listDataFenzha.push(fenzhaData)


				// 设置序号
				/*this.listDataFenzha.forEach((item, index) => {

					item.data.forEach((e) => {
						if (e.title == '扎号') {
							e.title = '扎号' + (index + 1)
						}
					})

				})*/
				console.log('121添加分扎', this.fenzhaData);
				/* uni.navigateTo({
					url: '/pages/cuttingOrder/AddASingleTie/AddASingleTie',
					success: res => {},
					fail: () => {},
					complete: () => {}
				}); */

			},

			Fenzha(e, index) {
				console.log('Fenzha', e, index)
				this.fenZhaIndex = index
				switch (e.title) {
					case '尺码大小':
						this.open(e)
						break;

					case '颜色外观':
						this.openColor()
						break;
					default:
						break;
				}

			},


			// 打开尺码弹框
			open(e) {
				console.log('点了');
				this.$refs.popupBag.open('bottom')
				console.log('列表点击事件', e);
				this.listItemData = e

				// 默认选中第一个
				this.sizeListData.forEach((item,index)=>{
					if(index==0){
						item.select=true
					}else{
						item.select=false
					}
				})


			},
			// 关闭尺码弹框
			close() {
				this.$refs.popupBag.close()
			},

			// 打开颜色弹框
			openColor(e) {
				console.log('点了');
				this.$refs.popupColor.open('bottom')
				console.log('列表点击事件', e);
				this.listItemData = e


				// 默认选中第一个
				this.colorListData.forEach((item,index)=>{
					if(index==0){
						item.select=true

					}else{
						item.select=false
					}
				})
				this.colorList.forEach((item,index)=>{
					if(index==0){
						item.select=true
					}else{
						item.select=false
					}
				})


			},
			// 关闭颜色弹框
			closeColor() {
				this.$refs.popupColor.close()
			},
			// 选择最终颜色
			addClick() {

				let select = '';

				this.colorList.forEach((item, index) => {
					// 表示点击选中
					if (item.select == true) {
						select = item
					}
				})
				if (select != '') {
					this.closeColor()
				} else {
					uni.showToast({
						title: '请选择颜色',
						icon: 'none'
					});
				}


				this.listDataFenzha[this.fenZhaIndex].data.forEach((item) => {
					if (item.title == '颜色外观') {

						// item.Value=select.sizeName
						this.$set(item, 'Value', select.colorName)
						console.log('2211颜色外观', this.listDataFenzha);
					}
				})

			},
      backOnClick() {
        uni.navigateBack({
          delta: 1
        });
        // console.log('点击返回');
      },
      createOrder(){
		  if (this.imgArr != undefined && this.imgArr.length > 0) {
		  	this.img = this.imgArr[0]
		  
		  }
        let data = {
          id: this.orderId,
          styleName: '',
          styleImgs: this.img,
          orderCode: '',
          customerName: '',
          customerStyle: '',
          price: 0,
          cost: 0,
          processList: [],
          splittingUpList: [],
        }
        this.listData.forEach(item=>{
          if(item.tableFie=='styleName'){
            data.styleName = item.Value
          }
          if(item.tableFie=='orderCode'){
            data.orderCode = item.Value
          }
          if(item.tableFie=='customerName'){
            data.customerName = item.Value
          }
          if(item.tableFie=='customerStyle'){
            data.customerStyle = item.Value
          }
          if(item.tableFie=='price'){
            data.price = item.Value
          }
          if(item.tableFie=='cost'){
            data.cost = item.Value
          }
        })
        this.listDataGongxu.forEach(item=>{
          let gx = {
            id: '',
            processName: '',
            processPrice: '0.00',
          }
          item.data.forEach(row=>{
            if(row.tableFie=='processName'){
              gx.processName = row.Value
            }
            if(row.tableFie=='wages'){
              gx.processPrice = row.Value
            }
          })
          gx.id = item.id===undefined?'':item.id
          data.processList.push(gx)
        })
        this.listDataFenzha.forEach(item=>{
          let fz = {
            id: '',
            bundleCode: '1',
            quantity: '0',
            sizes: '',
            colors: '',
            batchs: '',
          }
          item.data.forEach(row=>{
            if(row.tableFie =='bundleCode'){
              fz.bundleCode = row.Value
            }
            if(row.tableFie=='quantity'){
              fz.quantity = row.Value
            }
            if(row.tableFie=='sizes'){
              fz.sizes = row.Value
            }
            if(row.tableFie=='colors'){
              fz.colors = row.Value
            }
            if(row.tableFie=='batchs'){
              fz.batchs = row.Value
            }
          })
          fz.id = item.id===undefined?'':item.id
          data.splittingUpList.push(fz)
        })

        console.log('updateOrder',data)
        updateOrder(data).then(res=>{
          if(res.code==200){
            let pages = getCurrentPages();
            let prevPage = pages[pages.length - 2]; //上一个页面
            //直接调用上一个页面的setData()方法，把数据存到上一个页面中去
            prevPage.setData({
              isRefresh: 1
            })
            this.backOnClick()
            // 显示提示信息
            uni.showToast({
              title: res.msg,
              icon: 'none'
            });
          }
        }).catch((err) => {
          console.log('新增失败', err);
        });
      },
		}
	}
</script>

<style lang="scss">
	.baseListItemColorRight {

		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		width: 500rpx;

		height: 100%;
		flex-wrap: wrap;

		// background-color: #0AE1C6;
	}

	.baseListItemColorLeftInnerText {

		font-family: HarmonyOS Sans SC;
		font-weight: 600;
		font-size: 24rpx;
		color: #333333;
		line-height: 100rpx;
		width: 100%;
		height: 100%;
		border-radius: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.baseListItemColorLeftInnerTextSelect {


		font-weight: 600;
		font-size: 24rpx;

		line-height: 100rpx;
		width: 100%;
		height: 100%;
		border-radius: 20rpx;
		background-color: red;
		color: #FFFFFF;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.baseListItemColorLeftInnerBg {
		width: 40rpx;
		height: 40rpx;
		border-radius: 10rpx;

		display: flex;
		justify-content: center;
		align-items: center;

		margin-right: 18rpx;


	}

	.baseListItemColorLeftInnerItemSelect {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 100%;

		border-radius: 20rpx;
	}

	.baseListItemColorLeftInnerItem {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 100%;


		border-radius: 20rpx;

	}

	.baseListItemColorLeftInnerItemRight {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-end;
		width: 216rpx;
		height: 80rpx;
		background: #F5F7F9;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
	}

	.baseListItemColorLeftInner {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		// justify-content: center;
		// align-items: center;

		width: 100%;
		height: 80rpx;
		margin-bottom: 20rpx;


	}

	.baseListItemColorLeft {
		display: flex;
		justify-content: flex-start;
		// align-items: center;
		flex-direction: column;
		width: 217rpx;
		height: 834rpx;
		background: #F5F7F9;

		border-radius: 20rpx;

	}

	.baseListItemColor {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: row;
		width: 750rpx;
		height: 834rpx;
		background: #FFFFFF;
		border-radius: 55rpx 55rpx 0rpx 0rpx;
	}


	.baseListItemText {

		font-size: 24rpx;
		color: #333333;
		line-height: 100rpx;
		text-align: center;
		font-style: normal;
		text-transform: none;
		font-weight: 600;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 217rpx;
		height: 80rpx;
		background: #F5F7F9;
		border-radius: 20rpx;

	}

	.baseListItemTextSelect {
		font-size: 24rpx;
		color: #FFFFFF;
		line-height: 100rpx;
		text-align: center;
		font-style: normal;
		text-transform: none;
		font-weight: 600;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 217rpx;
		height: 80rpx;
		background: red;
		border-radius: 20rpx;
		border: red solid 1rpx;


	}



	.baseListItemColorRightItem {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: flex-start;
		flex-wrap: wrap;
		width: 100%;
		height: 100rpx;
		margin-left: 30rpx;

		// flex: 0 0 calc((100%)/2);




	}

	.baseListItem {
		display: flex;
		flex-direction: column;
		align-items: center;

		flex: 0 0 calc((100%)/3);
		margin-bottom: 20rpx;

	}


	.baseListColor {

		display: flex;
		flex-direction: column;
		width: 100%;
		flex-wrap: wrap;
		justify-content: center;
		margin-top: 29rpx;

	}

	.baseList {
		display: flex;
		flex-direction: row;
		width: 100%;
		flex-wrap: wrap;
		margin-top: 29rpx;
	}

	.baseListColor {
		display: flex;
		flex-direction: row;
		width: 500rpx;
		flex-wrap: wrap;

	}




	.bagDetailUpadte {
		width: 100%;
		height: 120rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 20rpx;
		/* border-radius: 20rpx 20rpx 0 0; */
		/* background-color: white; */
	}

	.bagDetailColor {

		width: 750rpx;
		height: 1073rpx;


		background: #FFFFFF;
		border-radius: 55rpx 55rpx 0rpx 0rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

	}

	.bagDetail {
		width: 750rpx;
		height: 603rpx;
		background: #FFFFFF;
		border-radius: 55rpx 55rpx 0rpx 0rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;





	}


	.loginContent {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 750rpx;



	}

	.loginContent1 {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 750rpx;

		position: absolute;
		bottom: 20rpx;


	}

	.login {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 20rpx;
		width: 690rpx;
		height: 100rpx;
		background: linear-gradient(90deg, #45A8FF, #0AE1C6);
		border-radius: 20rpx;
		margin-bottom: 20rpx;


		font-weight: 400;
		font-size: 36rpx;
		color: #FFFFFF;
		text-align: center;
		font-weight: bold;


		background: linear-gradient(90deg, #45A8FF, #0AE1C6);

	}


	.contentAddBtnOut {
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 30rpx;
		margin-bottom: 30rpx;

		.contentAddBtnInner {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 630rpx;
			height: 80rpx;
			background: #ECF5FD;
			border-radius: 20rpx;

			.contentAddBtnInnerImg {
				width: 22rpx;
				height: 22rpx;
			}

			.contentAddBtnInnerText {
				font-family: HarmonyOS Sans SC;
				font-weight: 600;
				font-size: 24rpx;
				color: #333333;
				line-height: 30rpx;
			}
		}

	}




	.content_gongxu {
		width: 630rpx;

		background: #F5F7F9;
		border-radius: 20rpx;

		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;


	}



	.contentItemTextRight {
		font-size: 28rpx;
		font-weight: 600;
		color: #666666;
		margin-right: 30rpx;
		width: 200rpx;
		text-align: right;
	}

	.contentItemTextLeftStart {
		color: red;
	}

	.contentItemTextLeftStartImg {
		width: 30rpx;
		height: 30rpx;
		margin-right: 30rpx;
	}

	.contentItemRightContentImg {
		width: 20rpx;
		height: 10rpx;
		margin-left: 15rpx;
		margin-right: 15rpx;

	}

	.contentItemTextLeft {
		font-size: 28rpx;
		font-weight: 600;
		color: black;
		margin-left: 30rpx;
	}

	.contentItem2 {
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-direction: row;

		width: 100%;
		height: 120rpx;


		/* background-color: aqua; */
	}



	.contentItemRightContent {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}


	.contentItemTextLeftContent {

		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}

	.contentItem {

		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-direction: row;

		width: 100%;
		height: 120rpx;

		border-radius: 30rpx 30rpx 0 0;
		/* background-color: aqua; */

	}


	.contentItem4 {
		margin-left: 20rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		/* background-color: bisque; */
	}

	.labelContent {
		font-size: 20rpx;
		font-weight: 600;
	}

	.contentItem3 {
		display: flex;
		align-items: center;
		flex-direction: row;
		justify-content: space-evenly;
		width: 100%;
		height: 120rpx;

	}

	.listContent {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 690rpx;

		background: #FFFFFF;
		border-radius: 30rpx;
	}

	.listContentGongxu {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100%;

		background: #F5F7F9;
		border-radius: 30rpx;

	}

	.lineBottom {
		width: 100%;
		height: 30rpx;
		background: #FFFFFF;
	}

	.listContentGongxuContent {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100%;

		background: #F5F7F9;
		border-radius: 30rpx;




	}


	.line {
		width: 100%;
		height: 1rpx;
		background: #EEEEEE;
	}

	.contentListOut {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		width: 100%;
		margin-top: 30rpx;
	}




	.contentImgAddBg {


		width: 190rpx;
		height: 190rpx;
		background: #F5F7F9;
		border-radius: 20rpx;



		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		position: relative;


		.contentImgAdd {
			width: 40rpx;
			height: 40rpx;



		}

		.contentImg2 {


			width: 150rpx;
			height: 150rpx;




		}

		.contentImgDeleteBg {
			width: 50rpx;
			height: 50rpx;
			background: #FF4E00;
			border-radius: 20rpx;

			display: flex;
			justify-content: center;
			align-items: center;
			position: absolute;
			bottom: 0rpx;
			right: 0rpx;

			.contentImgDelete {
				width: 30rpx;
				height: 30rpx;



			}


		}

		.contentText {
			width: 100%;
			text-align: center;
			font-family: HarmonyOS Sans SC;
			font-weight: 600;
			font-size: 18rpx;
			color: #999999;
			line-height: 120rpx;
		}
	}

	.contentOutInner {

		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

	}

	.contentOut {

		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		width: 690rpx;

		background: #FFFFFF;
		border-radius: 30rpx;
	}

	.imagepage {

		background-size: cover;
		background-repeat: no-repeat;
		background-position: center center;
		position: absolute;
		z-index: -1;
		left: 0;
		right: 0;
		bottom: 0;
		right: 0;
		width: 100%;
		height: 100%;

	}
</style>
